package com.hins.play;

import com.hins.play.anno.InvokeRecordAnno;
import com.hins.play.anno.RestrictRequestAnno;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;

import java.lang.reflect.Method;
import java.util.HashMap;

/**
 * Description: 666
 *
 * @author wenjiaqi
 * @date 2021/5/11 18:29
 */
public class RestrictRequestHandler extends BaseMethodAdviceHandler<Object>{

    @Override
    public boolean onBefore(ProceedingJoinPoint point) {
        Method targetMethod = getTargetMethod(point);

        RestrictRequestAnno anno = targetMethod.getAnnotation(RestrictRequestAnno.class);
        int number = anno.number();
        int time = anno.time();
        // 这里可考虑使用redis过期时间，加次数

        if (time >= 9) {
            return false;
        }
        return false;
    }

    @Override
    public Object getOnForbid(ProceedingJoinPoint point) {
        HashMap<Object, Object> m = new HashMap<>();
        m.put("", "");
        return m;
    }
}
